package com.example.springbootsfzy.service.sunkaixuan;

import com.example.springbootsfzy.domain.ConsultationReviews;
import com.example.springbootsfzy.mapper.ConsultationReviewsMapper;
import com.example.springbootsfzy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConsultationReviewsService {

    @Autowired
    private ConsultationReviewsMapper consultationReviewsMapper;

    //用List接收查询结果
    public List<ConsultationReviews> getConsultationReviews() {
        List<ConsultationReviews> consultationReviews = consultationReviewsMapper.selectAll();
        return consultationReviews;
    }

    //添加新评价
    public int addConsultationReview(ConsultationReviews consultationReviews) {
        int i = consultationReviewsMapper.insert(consultationReviews);
        return i;
    }

    //根据memberid获取
    public List<ConsultationReviews> selectByMemberId(int id) {
        List<ConsultationReviews> consultationReviews = consultationReviewsMapper.selectAll();
        return consultationReviews;
    }

    //根据consultationId获取
    public List<ConsultationReviews> selectByAppointmentId(int id) {
        List<ConsultationReviews> consultationReviews = consultationReviewsMapper.selectByConsultationId(id);
        return consultationReviews;
    }

    //删除
    public int deleteByReviewId(int id) {
        int i = consultationReviewsMapper.deleteByReviewId(id);
        return i;
    }

    //修改
    public int updateConsultationReview(ConsultationReviews consultationReviews) {
        int i = consultationReviewsMapper.updateByReviewId(consultationReviews);
        return i;
    }

}
